package com.weipt.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.FanoutExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author weipt
 * @description rabbitmq配置类-fanout模式
 * @date 2024/1/9 22:23
 */
@Configuration
public class FanoutRabbitMqConfig {

    @Bean
    public FanoutExchange fanoutExchange(){
        return new FanoutExchange("fanout-exchange-springboot", true, false);
    }

    @Bean
    public Queue smsQueue(){
        return new Queue("sms-queue", true);
    }

    @Bean
    public Queue emailQueue(){
        return new Queue("email-queue", true);
    }

    @Bean
    public Queue msgQueue(){
        return new Queue("msg-queue", true);
    }

    @Bean
    public Binding smsBinding(){
        return BindingBuilder.bind(smsQueue()).to(fanoutExchange());
    }

    @Bean
    public Binding emailBinding(){
        return BindingBuilder.bind(emailQueue()).to(fanoutExchange());
    }

    @Bean
    public Binding msgBinding(){
        return BindingBuilder.bind(msgQueue()).to(fanoutExchange());
    }


}
